{% extends 'template.html' %}
{% load staticfiles %}

{% block username %}
    {{ request.user.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h2 class="page-header">{{ salt_task.name }}-选择执行任务的主机</h2>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <button type="button" class="btn btn-primary" id="bt-commit">准备执行</button>
                        <a type="button" class="btn btn-danger" href="/assets/salt_task_execute_history/{{ salt_task.id }}/">历史记录</a>
                        <a type="button" class="btn btn-success" href="{% url 'system_cron_list' %}">返回</a>
                    </div>
                    <div class="panel-body">
                        <div class="form-group row">
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <label class="control-label">地区:</label>&nbsp;&nbsp;
                            <select class="col-sm-1" id="id_area" name="area">
                                <option value="0">全部</option>
                            </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <label class="control-label">项目:</label>&nbsp;&nbsp;
                            <select class="col-sm-2" id="id_project" name="project">
                                <option value="全部">全部</option>
                            </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <label class="control-label">机房:</label>&nbsp;&nbsp;
                            <select class="col-sm-2" id="id_room" name="room">
                                <option value="全部">全部</option>
                            </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </div>
                        <table id="mytable" class="display" width="100%" cellspacing="0">
                            <thead>
                            <tr>
                                <th class="center sorting_disabled">
                                    <label class="pos-rel">
                                        <input id='chb-all' type="checkbox"/>
                                    </label>
                                </th>
                                <th>主机id</th>
                                <th>地区</th>
                                <th>所在项目</th>
                                <th>所在机房</th>
                                <th>状态</th>
                                <th>业务类型</th>
                                <th>平台</th>
                                <th>局域网IP</th>
                                <th>电信ip</th>
                                <th>联通ip</th>
                                <th>用途</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Edit Execute Host Modal-->
    <div class="modal fade" id="Modal-execute-host" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width:800px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">执行任务-{{ salt_task.name }}</h4>
                </div>
                <div class="modal-body" style="height:700px;overflow:auto;">
                    <input type="text" style="display: none" id="execute_task_id" value="{{ salt_task.id }}">
                    <textarea readonly rows="28" cols="100" style="min-width: 100%"
                              id="execute_result"></textarea>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-info" onclick="clear_result()">清空结果</button>
                    <button type="button" class="btn btn-success" onclick="start_execute()">开始执行</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>

    <div id="is_superuser" data-is-superuser="{{ is_superuser }}"></div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/jquery.dataTables.js"></script>
    <script src="/static/js/reconnecting-websocket.js"></script>
    <script src="/static/js/system_cron_execute.js?v=20190515001"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/system_cron_execute.css" rel="stylesheet" type="text/css">
    <link href="/static/css/jquery.dataTables.css" rel="stylesheet" type="text/css">
{% endblock %}
